<template>
  <IBizRow :class="[ns.b(), ns.m(modelData.codeName), classArr]" :layout="modelData.layout">
    <template v-for="slotKey in Object.keys($slots)" :key="slotKey">
      <IBizCol :layoutPos="modelData.layoutPos" :state="controller.state">
        <slot :name="slotKey"></slot>
      </IBizCol>
    </template>
  </IBizRow>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { IPanelContainer } from '@ibiz/model-core'
import { PanelItemController } from '@ibiz-template/runtime'
import { useNamespace } from '@/use'

// 定义组件接收的属性
const props = defineProps({
  modelData: {
    type: Object as PropType<IPanelContainer>,
    required: true,
  },
  controller: {
    type: PanelItemController,
    required: true,
  },
})

// 获取命名空间和计算类名数组
const ns = useNamespace('panel-tab-page')
const classArr = computed(() => {
  const { id } = props.modelData
  const result: Array<string | false> = [ns.b(), ns.m(id)]
  if (props.controller) {
    result.push(...props.controller.containerClass)
  }
  return result
})
</script>
